package org.deltaset.desktop;

import java.io.Serializable;
import java.util.List;

/**
 *
 * @author dmakariev
 */
public class AppItem implements Serializable, Permission {

    private final String appId;
    private final String appTitle;
    private final String appSrc;
    private final List<MenuGroup> menuGroups;
    private final MenuItem defaultMenuItem;
    private final String permission;

    public AppItem(AppItem ai, PermissionFilter filter) {
        this.appId = ai.appId;
        this.appTitle = ai.appTitle;
        this.appSrc = ai.appSrc;
        this.defaultMenuItem = ai.defaultMenuItem;
        this.permission = ai.permission;
        this.menuGroups = PermissionUtil.filterMenuGroup(ai.menuGroups, filter);
    }

    public AppItem(String appId, String appTitle, String appSrc, MenuItem defaultMenuItem, List<MenuGroup> menuGroups, String permission) {
        this.appId = appId;
        this.appTitle = appTitle;
        this.appSrc = appSrc;
        this.menuGroups = menuGroups;
        this.defaultMenuItem = defaultMenuItem;
        this.permission = permission;
    }

    public String getAppId() {
        return appId;
    }

    public String getAppSrc() {
        return appSrc;
    }

    public String getAppTitle() {
        return appTitle;
    }

    public MenuItem getDefaultMenuItem() {
        return defaultMenuItem;
    }

    public List<MenuGroup> getMenuGroups() {
        return menuGroups;
    }

    @Override
    public String getPermission() {
        return permission;
    }
}
